import request from "./request.js";

//***************************************************************************** */
//登录页面接口
//*************************************************************************** */
function login(data) {
  //获取验证码
  return request.post('api/login/send', {
    mobile: data.mobile,
  })
}

//验证码登录
function loginverify(data) {
  return request.post('api/login/loginCode', {
    mobile: data.mobile,
    code: data.code
  })
}
//密码登录
function loginpassword(data) {
  return request.post('api/login/sign', {
    mobile: data.mobile,
    password: data.password
  })
}
//注册账号
function register(data) {
  return request.post('api/login/register', {
    mobile: data.mobile,
    code: data.code,
    password: data.password,
    passwords: data.passwords
  })
}
//***************************************************************************** */
//index页面接口
//*************************************************************************** */
// 轮播图
function banner(data, config) {
  // console.log(config); 

  return request.get('api/banner')
}
//金刚区
function Kong(data, config) {
  return request.get('api/link')
}
//商品列表
function goodslist(data, config) {
  return request.get('api/index/newGoods')
}

//***************************************************************************** */
//地址管理--获取地址列表
//*************************************************************************** */
function addresslist(data, config) {
  return request.get('api/address/address-list', {}, {
    isAuth: true
  })
}
//地址管理--添加地址
function addressUpdata(data, config) {
  return request.post('api/address/create', {
    name: data.name,
    phone: data.phone,
    city: data.city,
    address: data.address,
    status: data.status
  }, {
    isAuth: true
  })
}

//地址管理--删除地址
function addressDelete(data, config) {
  return request.delete('api/address/delete', {
    id: data.id
  }, {
    isAuth: true
  })
}

//地址管理--修改地址--获取原地址
function addresschange_id(data, config) {
  return request.post('api/address/addone', {
    id: data.id
  }, {
    isAuth: true
  })
}
//地址管理--修改地址--上传地址
function addresschange(data, config) {
  return request.post('api/address/update', {
    name: data.name,
    phone: data.phone,
    city: data.city,
    address: data.address,
    id: data.id
  }, {
    isAuth: true
  })
}
//购物车--获取购物车列表
function cartlist(data, config) {
  return request.post('api/cart/cart', {}, {
    isAuth: true
  })
}
export default {
  login,
  loginverify,
  register,
  loginpassword,
  banner,
  Kong,
  addresslist,
  addressUpdata,
  addressDelete,
  goodslist,
  addresschange_id,
  addresschange,
  cartlist
}


